package com.lang;

import java.io.UnsupportedEncodingException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.UUID;

public class Ttt {

	/**
	 * @param args
	 * @throws ClassNotFoundException 
	 * @throws SQLException 
	 * @throws UnsupportedEncodingException 
	 */
	public static void main(String[] args) throws ClassNotFoundException, SQLException, UnsupportedEncodingException {
		// TODO Auto-generated method stub
		System.err.println(UUID.randomUUID().toString());
		
		Class.forName("com.mysql.jdbc.Driver");
		//?useUnicode=true&amp;characterEncoding=UTF-8
		//?useUnicode=true&amp;characterEncoding=utf8
		//10.16.182.175
		Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?characterEncoding=gbk", "root", "root");
//		Connection con = DriverManager.getConnection("jdbc:mysql://10.16.182.175:3306/test?characterEncoding=utf8", "root", "admin");
		
		
//		 java.util.Properties prop = new java.util.Properties();
//	       prop.put( "charSet" , "utf8" );
//	       prop.put( "user" , "root");
//	       prop.put( "password" , "root");
//	       Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=UTF-8", prop);

		
		String sql = "";
		
		
//		ResultSet q = con.createStatement().executeQuery("select * from teacher");
//		if(q.next()){
//			String q1 = q.getString(1);
//			String q2 = q.getString(2);
//			String q3 = q.getString(3);
//			String q4 = q.getString(4);
//			System.err.println(q1+q2+q3+q4);
//		}
		
		
		sql = "insert into TEACHER(     TEACHERID,    NAME  )values(    '"+System.currentTimeMillis()+"' ,    'java' )  ";
		System.err.println(sql);
		con.createStatement().execute(sql);
		
		con.close();
	}
	

}
